#!/usr/bin/env python3# -*- coding: utf-8 -*-#@file   :SeleniumDemo.py#@time   :2018/5/26 1:02#@Author :jmgen#@Version:1.0#@Desc   :from selenium import webdriverfrom selenium.webdriver.common.keys import Keysimport timedriver = webdriver.Chrome()driver.get("https://www.baidu.com/")assert u"百度" in driver.titleusername = driver.find_element_by_id('kw')search_button = driver.find_element_by_xpath("//input[@type='submit']")username.send_keys("美女")search_button.click()time.sleep(8)# username.send_keys(Keys.RETURN)time.sleep(3)assert u"美女" in driver.page_sourcedriver.close()